//
//  ESTActivityModel.m
//  ESTSCRMAPP
//
//  Created by 李贤立 on 2018/10/8.
//  Copyright © 2018年 Capfer. All rights reserved.
//

#import "ESTActivityModel.h"

@implementation ESTActivityModel
/**
 请求所有有效的活动
 
 @param success 成功回调
 @param failure 失败回调
 */
+ (void)requestAllActivitySuccess:(void(^)(NSArray<ESTActivityModel *> *modelArray))success failure:(void(^)(NSString *error))failure {
    [self requestAllActivityWithIS_ENABLE:YES page_num:0 success:success failure:failure];
}
/**
 请求所有的活动数据

 @param is_enable 是否有效
 @param page_num 第几页
 @param success 成功回调
 @param failure 失败回调
 */
+ (void)requestAllActivityWithIS_ENABLE:(NSInteger)is_enable page_num:(NSInteger)page_num success:(void(^)(NSArray<ESTActivityModel *> *modelArray))success failure:(void(^)(NSString *error))failure {
    NSDictionary *dict;
    if (page_num == 0) {
        dict = @{
                 @"IS_ENABLE": @(is_enable)
                 };
    } else {
        dict = @{
                 @"IS_ENABLE": @(is_enable ),
                 @"PAGE_NUM" : @(page_num),
                 @"PAGE_SIZE" : @(Request_PageSize_Activity)
                 };
    }
    [NetTool postWithCode:Code_All_Activity parameter:dict success:^(NSDictionary *result) {
        NSArray *arr = [NSArray arrayWithArray:result[@"DATA_INFO"]];
        NSMutableArray *arrayM = [ESTActivityModel mj_objectArrayWithKeyValuesArray:arr];
        if (success) {
            success([arrayM mutableCopy]);
        }
    } failure:^(NSString *error) {
        if (failure) {
            failure(error);
        }
    }];
}
@end
